package com.cmpe451.nutty.model;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

@Entity
@Table(name = "APP_ROLE")
public class Role implements Serializable {
    private static final long serialVersionUID = 1L;

    @Id
    @Column(name = "ROLE_NAME", length = 100, unique = true)
    private String name;

    @Column(name = "ROLE_DESCRIPTION", length = 256, nullable = true)
    private String description;

    @ManyToMany
    @JoinTable(name = "APP_ROLE_PRIVILEGE", joinColumns = { @JoinColumn(name = "APP_ROLE_NAME") }, inverseJoinColumns = { @JoinColumn(name = "APP_PRIVILEGE_NAME") })
    private Set<Privilege> privileges = new HashSet<Privilege>();

    public String getName() {
	return name;
    }

    public void setName(String name) {
	this.name = name;
    }

    public String getDescription() {
	return description;
    }

    public void setDescription(String description) {
	this.description = description;
    }

    public Set<Privilege> getPrivileges() {
	return privileges;
    }

    public void setPrivileges(Set<Privilege> privileges) {
	this.privileges = privileges;
    }

}
